
// this js file is used in HtmlEditor.mxml

// the target html or jsp page must contains the following div element
// <div id="iframeEditor" style="position:absolute;background-color:transparent;border:0px;visibility:hidden;"></div>

function loadEditor(sIFrameId, url){
	var frameDiv = document.getElementById(sIFrameId);
	frameDiv.innerHTML = "<iframe id='" + sIFrameId + "_editor' src='" + url + "' frameborder='0'></iframe>";
}

function moveEditor(sIFrameId, x, y, w, h) {
	var frameDiv = document.getElementById(sIFrameId);
	frameDiv.style.left = x;
	frameDiv.style.top = y;
	
	var iFrame = document.getElementById(sIFrameId + "_editor");	
	if(iFrame){
		iFrame.width = w;
		iFrame.height = h;
	}
}

function setEditorVisibility(sIFrameId, bVisible){
	var visibility = bVisible ? "visible" : "hidden";
	var frameDiv = document.getElementById(sIFrameId);
	frameDiv.style.visibility = visibility;
}

var htmleditor_initdata='';
function setContent(sIFrameId, content){
	var frameName = sIFrameId + "_editor";	
	try{
		htmleditor_initdata = content;
		document.frames(frameName).setEditorValue(content);
	}catch(e){}
}
function getContent(sIFrameId){
	var frameName = sIFrameId + "_editor";
	try{
		return document.frames(frameName).getEditorValue();
	}catch(e){}
	return '';
}

function getHtmlEditorUploadUrl(sIFrameId) {
	var frameName = sIFrameId + "_editor";
	try{
		return document.frames(frameName).getHtmlEditorUploadUrl();
	}catch(e){}
	return '';
}

function getHtmlEditorUploadPhysicalPath(sIFrameId) {
	var frameName = sIFrameId + "_editor";
	try{
		return document.frames(frameName).getHtmlEditorUploadPhysicalPath();
	}catch(e){}
	return '';
}
